package br.com.paiva.container.util;

import javax.faces.context.FacesContext;

import br.com.paiva.container.Usuario;

public class UserSessao {

	private static UserSessao instance = null;
	
	public UserSessao(){
		
	}
	
	public static UserSessao getInstance(){
		
		if(instance == null){
			instance = new UserSessao();
		}
		
		return instance;
	}
	
	public void addUserSessao(Usuario usuario) throws Exception{
		FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("usuarioLogado", usuario);
	}
	
	public Usuario userLogadoSessao() throws Exception{
		
		Usuario userSessao = (Usuario)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("usuarioLogado");
		
		return userSessao;
	}
	
	public void removeUserSessao(){
		
		FacesContext.getCurrentInstance().getExternalContext().getSessionMap().clear();
	}
}
